package com.unhz.taigu.controller;


import com.unhz.generator.pojo.Insole;
import com.unhz.generator.pojo.KidsDict;
import com.unhz.generator.pojo.ManShoesDict;
import com.unhz.generator.pojo.WomenShoesDict;
import com.unhz.taigu.service.InsoleService;
import com.unhz.taigu.service.KidsService;
import com.unhz.taigu.service.ManShoesService;
import com.unhz.taigu.service.WomenShoesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;


/**
 * @Author: 沈佳庆
 * @Description:
 * @Date: Created in 上午 10:11 2018/2/2 0002
 * @Modified By:
 */
@Controller
@RequestMapping("/shoesSize")
public class ShoesSizeConterller {

    @Autowired
    private WomenShoesService womenShoesService;

    @Autowired
    private ManShoesService manShoesService;

    @Autowired
    private KidsService kidsService;

    @Autowired
    private InsoleService insoleService;

    @RequestMapping("/findShoesSize")
    @ResponseBody
    public List findShoesSize(@RequestParam(value = "shoesType",defaultValue = "0",required = true) Integer shoesType,
                                @RequestParam(value = "model",defaultValue = "0",required = true) String model){
        String shoesSize = null;
        if("0".equals(model)){
            shoesSize = "M";
        }else{
            Insole insole = insoleService.selectInsoleByModel(model);
            shoesSize = insole.getShoesType();
        }

        List list = new ArrayList();
        if("K".equals(shoesSize)){
            List<KidsDict> kidsDictList = kidsService.findKidsSize(shoesType);
            for(KidsDict kidsDict:kidsDictList){
                list.add(kidsDict.getSize());
            }
        }
        if ("M".equals(shoesSize)){
            List<ManShoesDict> manShoesDictList = manShoesService.findMansShoesSize(shoesType);
            for(ManShoesDict manShoesDict:manShoesDictList){
                list.add(manShoesDict.getSize());
            }
        }
        if("W".equals(shoesSize)){
            List<WomenShoesDict> womenShoesDictList = womenShoesService.findWomenShoesSize(shoesType);
            for(WomenShoesDict womenShoesDict:womenShoesDictList){
                list.add(womenShoesDict.getSize());
            }
        }
        return list;
    }



}
